const {
  $util,
} = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list: [],
    page: 1,
    hasMore: true,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(ops) {
    this.getList();
    wx.setNavigationBarTitle({
      title: ops.barTitle && decodeURIComponent(ops.barTitle) || '廉政建设',
    });
  },
  getList() {
    $util.request({
      url: 'entry/wxapp/edu.incorruptgov.getdoc',
      data: {
        page: this.data.page,
      },
      showLoading: false,
      success: (res) => {
        let list = res.list;
        if (this.data.page > 1) {
          list = [...this.data.list, ...list];
        }
        this.setData({
          list,
          hasMore: res.list.length !== 0,
          loaded: true,
          page: res.list.length !== 0 ? this.data.page + 1 : this.data.page,
        });

      },
    });
  },
  onReachBottom() {
    if (this.data.hasMore) {
      this.getList();
    }
  },
  onShareAppMessage() {
    let _this = this;
    let path = '/ws_party_const/pages/education/probity/file/index';
    let res = {
      path,
    };
    return res;
  },
});